package com.skp.shaphan.internalStorage;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Version_0_2 implements StructureVersion {

	@Override
	public Version getVersion() {
		return new Version(0, 2);
	}

	@Override
	public void updateDatabase(Connection connection) throws SQLException {
		Statement st = connection.createStatement(ResultSet.CONCUR_UPDATABLE, ResultSet.FETCH_FORWARD);
		st.execute("alter table " + Tables.Dev + " " +
				"add column " + Fields.Dev_UseJavaFX +" char(1) DEFAULT 'N' " 
				);
		st.execute("create table " + Tables.DevSQL + " (" +
				Fields.DevSQL_ID +" INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), " +
				Fields.DevSQL_Order +" int, " +
				Fields.DevSQL_Name +" char(50), " +
				Fields.DevSQL_Text +" long varchar, " +
				"primary key (" + Fields.DevSQL_ID +" )  )");
		st.execute("create table " + Tables.SQLHistory + " (" +
				Fields.SQL_ID +" INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), " +
				Fields.SQL_Date +" int, " +
				Fields.SQL_Name +" char(50), " +
				Fields.SQL_Text +" long varchar, " +
				"primary key (" + Fields.SQL_ID +" )  )");
		st.close();
	}
}
